import http from './http'


//专题列表
function specialList() {
    return http.post('/course-api/api/bbs/bbsCategory/open/list')
}

//帖子列表
function classifyList(categoryId) {
    let form = new URLSearchParams();
    // form.append('pageSize',pageSize)
    // form.append('pageNum',pageNum)
    form.append('categoryId',categoryId)
    return http.post('/course-api/api/bbs/bbsPosts/open/list',form)
}
function classifyListTwo(title) {
    let form = new URLSearchParams()
    // form.append('pageSize',pageSize)
    // form.append('pageNum',pageNum)
    form.append('title',title)
    return http.post('/course-api/api/bbs/bbsPosts/open/list',form)
}
//歌手分类列表
function singer() {
    return http.get('/music-api/artist/list')
}
//获取歌手歌单
function singerList(id) {
    return http.get(`/music-api/artists?id=${id}`)
}
//获取音乐url
function musicUrl(urlId) {
    return http.get(`/music-api/song/url?id=${urlId}`)
}






//详情接口
function detailList(postsId) {
    return http.get(`/course-api//api/bbs/bbsPosts/open/detail/${postsId}`,)
}

//获取评论接口
function commentsList(postsId) {
    let urlParams = new URLSearchParams()
    urlParams.append('postsId',postsId)
    return http.post('/course-api/api/bbs/bbsComment/open/list',urlParams)
}

//回复列表
function replyCommentsList(parentId) {
    let urlParams = new URLSearchParams()
    // urlParams.append('postsId',postsId)
    urlParams.append('parentId',parentId)
    return http.post('/course-api/api/bbs/bbsComment/open/reply/list',urlParams)
}

//发表言论
function addComment(postsId,commentContent) {
    let urlParams = new URLSearchParams()
    urlParams.append("postsId",postsId)
    urlParams.append("commentContent",commentContent)
    return http.post('/course-api/api/bbs/bbsComment/site/add',urlParams)
}

//回复言论
function replyCommit(postsId,parentId,commentContent) {
    let urlParams = new URLSearchParams()
    urlParams.append('postsId',postsId)
    urlParams.append('parentId',parentId)
    urlParams.append('commentContent',commentContent)
    return http.post('/course-api/api/bbs/bbsComment/site/reply/add',urlParams)
}

//删除言论
function removeComment(ids) {
    let urlParams = new URLSearchParams()
    urlParams.append('ids',ids)
    return http.post('/course-api/api/bbs/bbsComment/site/remove',urlParams)
}


//短信验证码
function getCode(mobile) {
    return http.get(`/course-api/api/short-message/vcode/${mobile}`)
}
//注册
function enrollList(loginName,code,phonenumber,password,userName,sex,remark) {
    let from =new URLSearchParams();
    from.append("loginName",loginName);
    from.append("code",code);
    from.append("phonenumber",phonenumber);
    from.append("password",password);
    from.append("userName",userName);
    from.append("sex",sex);
    from.append("remark",remark);
    return http.post('/course-api/api/registry', from)
}
//登录
function login(username,password) {
    let from =new URLSearchParams();
    from.append("username",username);
    from.append("password",password);
    from.append("rememberMe",true);
    return http.post('/course-api/api/login',from)
}
//忘记密码
function forgetPwd(loginName,password,phonenumber,code) {
    let from=new URLSearchParams();
    from.append("loginName",loginName);
    from.append("password",password);
    from.append("phonenumber",phonenumber);
    from.append("code",code);
    return http.post('/course-api/api/password/forget',from)
}
//修改头像
function setAvatar(avatarfile) {
    let from =new FormData();
    from.append("avatarfile",avatarfile);
    return http.post('/course-api/api/system/user/profile/update/avatar/nos',from)
}
//上传图片
function  upImg(file,fileUseForEnum) {
    let from=new FormData();
    from.append("file",file);
    from.append("fileUseForEnum",fileUseForEnum);
    return http.post('/course-api/api/nos/upload/image',from)
}
//修改个人信息
function setInfo(userName,sex,remark) {
    let from=new URLSearchParams();
    from.append("userName",userName);
    // from.append("phonenumber",phonenumber);
    from.append("sex",sex);
    from.append("remark",remark);
    return http.post('/course-api/api/system/user/profile/update',from)
}
//退出登录
function logout() {
    return http.get('/course-api/api/logout')
}
//点赞
function getLike(articleId) {
    return http.get(`/course-api/api/cms/article/add/zan/{articleId}_1611232428940?${articleId}`);
}
//获取个人信息
function getinformain() {
    return http.get('/course-api/api/login-user/info')
}



//发表帖子
function publishedS(publishedV,text1,text2,fileList) {
    let Sub = new URLSearchParams()
    Sub.append('categoryId',publishedV)
    Sub.append('title',text1)
    Sub.append('intro',text2)
    Sub.append('coverImgUrl',fileList)
    return http.post('/course-api/api/bbs/bbsPosts/site/add',Sub)
}
//上传图片
function pictureL(file) {
    let pictureL = new FormData();
    pictureL.append('file',file)
    pictureL.append('fileUseForEnum','BBS')
    return http.post('/course-api/api/nos/upload/image',pictureL)
}

//删除帖子
function deletes(ids) {
    let urlParams = new URLSearchParams()
    urlParams.append('ids',ids)
    return http.post('/course-api/api/bbs/bbsPosts/site/remove',urlParams)
}
//我参与的
function participate() {
    return http.post('/course-api/api/bbs/bbsPosts/join/list')

}




//笑话
function xiaohua(pagenum,pagesize) {
    // https://api.jisuapi.com/xiaohua/text?pagenum=1&pagesize=1&sort=addtime&appkey=5e4c24223a7efc01
    return http.get(`/xiaohuaApi/xiaohua/text?pagenum=${pagenum}&pagesize=${pagesize}&sort=addtime&appkey=5e4c24223a7efc01`)
}
export {
    addComment,
    specialList,
    classifyList,
    detailList,
    commentsList,
    replyCommentsList,
    removeComment,
    replyCommit,
    classifyListTwo,
    singer,
    musicUrl,
    singerList,
    getCode,
    enrollList,
    login,
    forgetPwd,
    setAvatar,
    upImg,
    setInfo,
    logout,
    getLike,
    getinformain,
    publishedS,
    pictureL,
    deletes,
    participate,
    xiaohua
}